package bdd.standalone.bean;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Bean CameraPlaning
 * @author Guillaume Pocas & Jean-Fraçois Augé
 */
@Entity
@Table(name = "cam_planning")
public class CameraPlanning {
	
	@Id
	@GeneratedValue
	@Column(name = "camplan_id")
	private int camplan_id;
	
	@ManyToOne
    @JoinColumn(name = "cam_id")
	private Camera camera;
	
	@ManyToMany(cascade = {CascadeType.ALL})
    @JoinTable(name="camplan_camopt",
                joinColumns={@JoinColumn(name="camopt_id")},
                inverseJoinColumns={@JoinColumn(name="camplan_id")})
    private Set<CameraOptions> list_camopt = new HashSet<CameraOptions>();
	
	@ManyToMany(cascade = {CascadeType.ALL})
    @JoinTable(name="camplan_treatlist",
                joinColumns={@JoinColumn(name="treat_id")},
                inverseJoinColumns={@JoinColumn(name="camplan_id")})
    private Set<Treatment> list_camtreat = new HashSet<Treatment>();
	
	@Column(name = "camplan_timeBegin", nullable = false)
	private Date camplan_timeBegin;
	
	@Column(name = "camplan_timeEnd", nullable = false)
	private Date camplan_timeEnd;
	
	@Column(name = "camplan_dayBegin", nullable = false)
	private Date camplan_dayBegin;
	
	@Column(name = "camplan_dayEnd", nullable = false)
	private Date camplan_dayEnd;
	
	@OneToMany(mappedBy="cameraPlanning")
    private Set<Planning> plannings;
	
	/**
	 * Constructeur vide.
	 */
	public CameraPlanning(){ }
	
	/**
	 * Créer un nouveau CameraPlaning
	 * @param timeBegin
	 * @param timeEnd
	 * @param dayBegin
	 * @param dayEnd
	 */
	public CameraPlanning(Date timeBegin, Date timeEnd, Date dayBegin, Date dayEnd){
		this.camplan_timeBegin = timeBegin;
		this.camplan_timeEnd = timeEnd;
		this.camplan_dayBegin = dayBegin;
		this.camplan_dayEnd = dayEnd;
	}

	public int getCamplan_id() { return camplan_id;	}
	public void setCamplan_id(int camplan_id) { this.camplan_id = camplan_id;	}

	public Camera getCamera() { return camera;	}
	public void setCamera(Camera camera) { this.camera = camera;	}

	public Set<CameraOptions> getList_camopt() { return list_camopt;	}
	public void setList_camopt(Set<CameraOptions> list_camopt) { this.list_camopt = list_camopt;	}

	public Date getCamplan_timeBegin() { return camplan_timeBegin;	}
	public void setCamplan_timeBegin(Date camplan_timeBegin) { this.camplan_timeBegin = camplan_timeBegin;	}

	public Date getCamplan_timeEnd() { return camplan_timeEnd;	}
	public void setCamplan_timeEnd(Date camplan_timeEnd) { this.camplan_timeEnd = camplan_timeEnd;	}

	public Date getCamplan_dayBegin() { return camplan_dayBegin;	}
	public void setCamplan_dayBegin(Date camplan_dayBegin) { this.camplan_dayBegin = camplan_dayBegin;	}
	
	public Date getCamplan_dayEnd() { return camplan_dayEnd;	}
	public void setCamplan_dayEnd(Date camplan_dayEnd) { this.camplan_dayEnd = camplan_dayEnd;	}

	public Set<Planning> getPlannings() { return plannings;	}
	public void setPlannings(Set<Planning> plannings) { this.plannings = plannings;	}
	
	public Set<Treatment> getList_camtreat() { return list_camtreat; 	}
	public void setList_camtreat(Set<Treatment> list_camtreat) { this.list_camtreat = list_camtreat;	}
	
}
